﻿
CREATE PROCEDURE [dbo].[exbug_GenRegistrulOrdonantari]
	@delaData datetime, 
	@panalaData datetime,
	@filtruArt varchar(8000),
	@delaNr decimal(18,0),
	@panalaNr decimal(18,0),
	@CodUnitate smallint
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    -- Insert statements for procedure here
	SELECT  NrDoc, DataDoc, ValoareLei, Scop, DocJust, ArtAl, CodUnitate
	FROM    dbo.Ordonantari
	WHERE (LEN(LTRIM(RTRIM(@filtruArt)))=0 OR (ArtAl IN (SELECT fart.value FROM dbo.SplitParameters(@filtruArt,',') fart))) AND
	(@delaNr=-1 OR NrDoc >= @delaNr) AND
	(@panalaNr=-1 OR NrDoc <= @panalaNr) AND
	DataDoc>=@delaData AND DataDoc <=@panalaData
	AND CodUnitate = @CodUnitate
END